import * as R from 'ramda'

export const sToNum = (s: string) => parseInt(s.trim())

export const sToNumArr = R.pipe(R.trim, R.split(' '), R.map(parseInt))

export const numArrToS = R.join(' ')

export function isAllZero(arr: number[]) {
	return R.all((x: number) => x === 0)(arr)
}

/**
 * 
 * @param x number array
 * @param y number array
 * @returns true means x >= y
 */
export const compareArrByEachElement = (x: number[], y: number[]) => {
	for (let i = 0; i < x.length; ++i) {
		if (x[i] < y[i]) {
			return false;
		}
	}
	return true;
}


export const testStringAllNumber = (arr: string[], resNum: number) => {
  const NumReg = /^[0-9]*$/
  return arr.length === resNum && R.all(NumReg.test)
}